package com.ruoyi.web.controller.system.api.cc;

import java.util.List;

import com.ruoyi.framework.interceptor.Authentication;
import com.ruoyi.system.api.ResponseWithData;
import com.ruoyi.system.api.domain.ServiceNotice;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.api.domain.ServicePart;
import com.ruoyi.system.api.service.IServicePartService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
 * 服务单关联备件信息Controller
 * 
 * @author shihx
 * @date 2020-03-16
 */
@Api(tags="服务单关联备件信息")
@Controller
@RequestMapping("/api/cc/ServicePart")
public class ServicePartController extends BaseController
{

    @Autowired
    private IServicePartService servicePartService;

    private static final Logger log = LoggerFactory.getLogger(ServicePartController.class);
    /**
     * 获取服务单关联的备件信息接口
     * @methodName: getServicePart
     * @description: TODO
     * @param ServiceNoticeId
     * @return: com.ruoyi.system.api.ResponseWithData<?>
     * @author: shihx
     * @date: 2020/3/18 10:59
    **/
    @GetMapping("/getServicePart")
    @ResponseBody
    @Authentication(tokenRequired = true, signRequired = true)
    @ApiOperation(value = "获取服务单关联的备件信息接口", httpMethod = "GET", notes = "获取服务单关联的备件信息接口")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "服务单主键ID", name = "ServiceNoticeId", required = true, defaultValue = "10009", dataType = "String", paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 500, message = "code 为 500 系统异常"),
            @ApiResponse(code = 200, message = "code 为 200 成功" ,response = ServiceNotice.class)
    })
    public ResponseWithData<?> getServicePart(
            @RequestParam(value="ServiceNoticeId",required=true) String ServiceNoticeId
    ){
        try {
            ServicePart servicePart = new ServicePart();
            servicePart.setServiceNoticeId(Long.parseLong(ServiceNoticeId));
            List<ServicePart> list = servicePartService.selectServicePartList(servicePart);
            return new ResponseWithData<>().success(list).msg("查询成功").code(200);
        }catch (Exception e){
            log.error("程序异常", e.getMessage());
            return new ResponseWithData().error().msg("系统异常").code(500);
        }
    }


}
